import MarkdownIt from 'markdown-it'
import { imagePlugin, linksPlugin } from "./plugins";
import hljs from 'highlight.js'

const imgSrcPrefix = '/images'

const md = MarkdownIt({
  highlight(str, lang) {
    if (lang && hljs.getLanguage(lang)) {
      try {
        return hljs.highlight(str, { language: lang }).value;
      } catch (__) {}
    }

    return ''; // use external default escaping
  }
})

md.use(imagePlugin)

md.use(linksPlugin)

export { md }